package thinkinginspring.spring.bean.definition;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import thinking.in.spring.ioc.container.overview.domain.User;

/**
 * BeanDefinitionAlias 实例
 */
public class BeanAliasDemo
{
    public static void main(String[] args)
    {
        String location = "classpath:META-INF/bean-definition-context.xml";
        BeanFactory beanFactory = new ClassPathXmlApplicationContext(location);

        User rubyUser = beanFactory.getBean("ruby-user", User.class);
        User user = beanFactory.getBean("user", User.class);

        System.out.println("通过别名rubyUser获取的Bean对象==通过Bean Id user获取的Bean对象 : " + (rubyUser == user));
    }
}
